package top.tangyh.lamp.care.mapper;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import top.tangyh.basic.base.mapper.SuperMapper;
import top.tangyh.lamp.care.entity.BHl7Medicine;
import org.springframework.stereotype.Repository;
import top.tangyh.lamp.care.vo.query.MedicineQueryVO;

import java.util.List;

import static top.tangyh.lamp.common.constant.CommonConstant.NO_NUMBER;

/**
 * <p>
 * Mapper 接口
 * 药物表
 * </p>
 *
 * @author zqb
 * @date 2024-08-09 16:23:52
 * @create [2024-08-09 16:23:52] [zqb] [代码生成器生成]
 */
@Repository
public interface BHl7MedicineMapper extends SuperMapper<BHl7Medicine> {

    default IPage<BHl7Medicine> selectPageListByQuery(MedicineQueryVO queryVO) {
        String medicineName = queryVO.getMedicineName();
        String typeName = queryVO.getTypeName();
        Integer page = queryVO.getPage();
        Integer size = queryVO.getSize();
        LambdaQueryWrapper<BHl7Medicine> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.like(StrUtil.isNotBlank(medicineName), BHl7Medicine::getMedicineName, medicineName)
                .like(StrUtil.isNotBlank(typeName), BHl7Medicine::getTypeName, typeName)
                .eq(BHl7Medicine::getIsDeleted, NO_NUMBER);
        IPage<BHl7Medicine> pageInfo = new Page<>(page, size);
        return this.selectPage(pageInfo, queryWrapper);
    }

    default List<BHl7Medicine> selectListByQuery(MedicineQueryVO queryVO) {
        String medicineName = queryVO.getMedicineName();
        String typeName = queryVO.getTypeName();
        LambdaQueryWrapper<BHl7Medicine> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.like(StrUtil.isNotBlank(medicineName), BHl7Medicine::getMedicineName, medicineName)
                .like(StrUtil.isNotBlank(typeName), BHl7Medicine::getTypeName, typeName)
                .eq(BHl7Medicine::getIsDeleted, NO_NUMBER);
        return this.selectList(queryWrapper);
    }
    
    
    
}


